package Java攻略._3_流式操作._4_利用reduce方法校验排序;

import java.math.BigDecimal;
import java.util.stream.Stream;

public class _29_利用reduce方法对BigDecimal求和 {

    public static void main(String[] args) {

        BigDecimal sum = Stream.iterate(BigDecimal.ONE, n -> n.add(BigDecimal.ONE))
                .limit(10)
                .reduce(BigDecimal.ZERO, (acc, val) -> acc.add(val));

        System.out.println(sum);
    }
}
